package cool.collection;

import java.util.*;

public class IteratorTest {
    public static void main(String args[]){
        Map<String,Student> map=new HashMap<>();
        List<String> list=new ArrayList<>();
        list.add("gaogao");
        list.add("shanshan");
        list.add("qingqing");
        for(int i=0;i<list.size();i++){
            System.out.print(list.get(i)+" ");
        }
        System.out.println();
        ListIterator<String> ll = list.listIterator();
        map.put("1001",new Student("1001","gaogao",25));
        map.put("1002",new Student("1002","shanshan",24));
        map.put("1003",new Student("1003","qingqing",18));
        for (String sno:map.keySet()){
          System.out.println(sno+" "+map.get(sno));
        }
        Set<String> sis=map.keySet();

        Iterator<String> its=sis.iterator();
        while (its.hasNext()){
            System.out.println(its.next());
        }
        Iterator<Map.Entry<String, Student>> ims = map.entrySet().iterator();
        while (ims.hasNext()){
            System.out.println(ims.next().getValue());
        }
        Set<Map.Entry<String, Student>> en = map.entrySet();
        for (Map.Entry<String,Student> me:en) {
            System.out.println(me.getKey()+" "+me.getValue());

        }



    }
}
class Student{
    private String SNo;
    private String name;
    private int age;

    @Override
    public String toString() {
        return "Student{" +
                "SNo='" + SNo + '\'' +
                ", name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public String getSNo() {
        return SNo;
    }

    public void setSNo(String SNo) {
        this.SNo = SNo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Student(String SNo, String name, int age) {
        this.SNo = SNo;
        this.name = name;
        this.age = age;
    }
}
